package fan.project3_pksystem.Mapper;

import fan.project3_pksystem.Module.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface UserMapper {
    @Select("select * from user_info where delete_flag =0")
    List<UserInfo> selectAllUserInfo();

//    @Select("select * from user_info where delete_flag =0 and ")
//    UserInfo selectUserInfoById(int id);

    @Select("select * from user_info where delete_flag = 0 and user_name = '${name}'")
    UserInfo selectUserInfoByName(String name);

    @Select("select * from user_info where delete_flag = 0 and Id = '${id}'")
    UserInfo selectUserInfoById(int id);

    @Insert("insert into user_info(user_name,password) values ('${userName}','${password}')")
    int register(String userName, String password);

    @Update("update user_info set score = score+10 ,total_count = total_count+1 ,win_count =win_count+1 where id = ${userId}")
    int winnerById(int userId);
    @Update("update user_info set score = score-8 ,total_count = total_count+1  where id = ${userId}")
    int loserById(int userId);
}
